package com.cn.controller.backstage;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.cn.controller.BaseServlet;
import com.cn.entity.Cycle_image_entity;
import com.cn.service.backstage_cycle_image_contlr;

@WebServlet("/backstage_slideshow")
public class backstage_slideshow extends BaseServlet {
	private backstage_cycle_image_contlr member;

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		member = new backstage_cycle_image_contlr();
		List<Cycle_image_entity> list = member.getmember();
		req.setAttribute("list", list);
		forward("backstage_slideshow");
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		String id = req.getParameter("xg_id");
		if (id != "" && id != null) {
			int xg_id = Integer.parseInt(req.getParameter("xg_id").toString());
			String xg_title = req.getParameter("xg_title");
			String xg_url = req.getParameter("xg_url");
			int xg_row = member.Upimg(xg_id, xg_url, xg_title);
			if (xg_row != -1) {
				System.out.println("修改成功");
			} else {
				System.out.println("修改失败");
			}
		}
		String add_title = req.getParameter("add_title");
		if (add_title != "" && add_title != null) {
			String add_url = req.getParameter("add_url");
			int add_row = member.addimg(add_url, add_title);
			if (add_row != -1) {
				System.out.println("添加成功");
			} else {
				System.out.println("添加失败");
			}
		}
		String[] deletimg = req.getParameterValues("checkboxs");
		if (deletimg!=null) {
			member.delet(deletimg);
		}
		member = new backstage_cycle_image_contlr();
		List<Cycle_image_entity> list = member.getmember();
		req.setAttribute("list", list);
		forward("backstage_slideshow");
	}
}
